﻿using UnityEngine;
using GraphProcessor;

namespace IQIGame.Onigao.GamePlay.Editors
{
    [System.Serializable, NodeMenuItem(SkillEditorConst.Skill + "/" + SkillEditorConst.SkillPart, typeof(SkillEditorGraph))]
    public class SkillPartNode : SkillPartBaseNode
    {
        public override Color color => Color.green;

        [Input(name = "启动")] public SkillEditorCondition last;
        public override string name => SkillEditorConst.SkillPart;

        protected override void Process()
        {
            base.Process();

            var rPart = this.self;
            if (this.last != null)
            {
                var rData = this.last;
                switch (rData.type)
                {
                    case ESkillEditorConditionType.True:
                        rData.condition.truePart = rPart.guid;
                        break;
                    case ESkillEditorConditionType.False:
                        rData.condition.falsePart = rPart.guid;
                        break;
                    case ESkillEditorConditionType.All:
                        if (rData.part != null)
                        {
                            rData.part.nextGUID = rPart.guid;
                        }
                        else if (this.last.trigger != null)
                        {
                            rData.trigger.triggerPart = rPart.guid;
                        }

                        break;
                }
            }
        }
    }
}